#ifndef VERTEX_H_INCLUDED
#define VERTEX_H_INCLUDED


#include "Vector3.h"
#include <vector>

namespace prog3d {

class Soup;

class Vertex {
private:
  Vector3 _p;
  Vector3 _n;
  int _number;
  int _nbNormal;
  Soup *_owner;
  void init(Soup *o);
public:
  Vertex(Soup *o,double x,double y,double z);
  Vertex(Soup *o,const Vector3 &p);
  Vertex(Soup *o);

  inline const Vector3 &point() const {
    return _p;
  }
  inline const Vector3 &normal() const {
    return _n;
  }
  inline void point(const Vector3 &p) {
    _p=p;
  }
  inline void normal(const Vector3 &n) {
    _n=n;
  }
  void set(const Vertex &s);

  void setNumber(int i);
  int getNumber();
  unsigned int number();

  void averageNormalBegin();
  void averageNormalAdd(const Vector3 &n);
  void averageNormalEnd();

  void translate(double x,double y,double z);
  void scale(double k);
  void scale(double kx,double ky,double kz);


  ~Vertex();
};

typedef Array<Vertex> AVertex;

}

#endif // VERTEX_H_INCLUDED
